<template>
  <div :class="this.$route.query.source === 'BF_PORTFOLIO' ? 'list-table noPad' : 'list-table'">
    <el-tabs v-if="this.$route.query.source === 'BF_PORTFOLIO'" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="$t('股权项目')" name="first">
        <bfInvestGroupList ref="bfInvestGroupList" />
      </el-tab-pane>
      <el-tab-pane :label="$t('基金项目')" name="second">
        <bfInvestFundList ref="bfInvestFundList" :show-title="false" />
      </el-tab-pane>
    </el-tabs>
    <div v-if="activeName === 'first'" style="padding: 0 20px;">
      <div class="area-header">
        <!--        <span v-if="this.$route.query.source !== 'BF_PORTFOLIO'" class="area-header-title">{{ $t('投资组合') }}</span>-->
        <span class="area-header-title">{{ $t('股权项目') }}</span>
      </div>
      <el-form ref="queryForm" :model="queryParams" :inline="true">
        <el-form-item v-if="this.$route.query.source === 'BF_PORTFOLIO'" :label="$t('基金名称')" prop="dealName">
          <el-input
            v-model="queryParams.dealName"
            :placeholder="$t('基金名称')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('公司名称')" prop="companyName">
          <el-input
            v-model="queryParams.companyName"
            :placeholder="$t('公司名称')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('公司简称')" prop="companyShortName">
          <el-input
            v-model="queryParams.companyShortName"
            :placeholder="$t('公司简称')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('标签')" prop="companyName">
          <el-input
            v-model="queryParams.tagsContext"
            :placeholder="$t('标签')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('更新时间')">
          <DatePicker
            v-model="dateRange"
            type="daterange"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['bf:investGroup:edit']"
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="addHandle"
          >{{ $t('新增') }}</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['bf:investGroup:import']"
            type="success"
            icon="el-icon-upload"
            size="mini"
            @click="upload.open = true;importHandle()"
          >{{ $t('导入') }}</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['bf:investGroup:export']"
            type="warning"
            icon="el-icon-download"
            size="mini"
            @click="exportHandle"
          >{{ $t('导出') }}
          </el-button>
        </el-col>
      </el-row>
      <el-table v-loading="loading" tooltip-effect="darkTable" :data="bfInvestGroupList" border>
        <el-table-column fixed="left" :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
          <template slot-scope="scope">
            {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column fixed="left" :label="$t('公司名称')" align="center" prop="company.companyName" show-overflow-tooltip min-width="180">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{path:'/company/base/companyBaseHome',query:{companyId:scope.row.indirectDealId, dealId:scope.row.dealId, source:'BF_PORTFOLIO'}}"
              class="link_a"
            >{{ scope.row.company.companyName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column v-if="this.$route.query.source === 'BF_PORTFOLIO'" :label="$t('基金名称')" align="center" prop="dealName" show-overflow-tooltip min-width="180">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{path:'/deal/home/dealBaseHome',query:{id:scope.row.dealId, companyId: scope.row.indirectDealId}}"
              class="link_a"
            >{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('公司简称')" align="center" prop="company.companyShortName" show-overflow-tooltip min-width="120" />
        <el-table-column :label="$t('投资时间')" align="center" prop="investmentTime" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.investmentTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('协议金额') + $t('金额单位')" align="center" prop="agreementAmount" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.agreementAmount, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('划款金额') + $t('金额单位')" align="center" prop="bfPortfolioVo.total" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.total, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('持股比例(%)')" align="center" prop="latestShareholdingRatio" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.latestShareholdingRatio) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投前公司估值') + $t('金额单位')" align="center" prop="bfPortfolioVo.preInvestmentVal" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.preInvestmentVal, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投后公司估值') + $t('金额单位')" align="center" prop="bfPortfolioVo.postInvestmentVal" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.postInvestmentVal, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('公司最新估值') + $t('金额单位')" align="center" prop="bfPortfolioVo.companyWholeVal" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.companyWholeVal, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目最新估值') + $t('金额单位')" align="center" prop="bfPortfolioVo.latestValuation" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.latestValuation, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已实现价值') + $t('金额单位')" align="center" prop="bfPortfolioVo.amountRecovered" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.amountRecovered, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('已处置成本') + $t('金额单位')" align="center" prop="bfPortfolioVo.exitCost" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.exitCost, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('回款收益') + $t('金额单位')" align="center" prop="bfPortfolioVo.realizedRevenue" show-overflow-tooltip min-width="140">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.realizedRevenue, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('在投本金') + $t('金额单位')" align="center" prop="bfPortfolioVo.costNotWithdrawn" show-overflow-tooltip min-width="140">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.costNotWithdrawn, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('未实现收益/损失') + $t('金额单位')" align="center" prop="bfPortfolioVo.loss" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.bfPortfolioVo.loss, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('未实现价值') + $t('金额单位')" align="center" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(formatMoney(scope.row.bfPortfolioVo.latestValuation) - formatMoney(scope.row.bfPortfolioVo.amountRecovered), 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('总估值倍数')" align="center" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(formatMoney(formatMoney(scope.row.bfPortfolioVo.latestValuation) / (scope.row.bfPortfolioVo.total)), 'rate', 2) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('上市情况')" align="center" prop="listedSituation" show-overflow-tooltip min-width="100" :formatter="listedSituationFormat" />
        <el-table-column :label="$t('上市板块')" align="center" prop="listedSector" show-overflow-tooltip min-width="100" :formatter="listedSectorFormat" />
        <el-table-column :label="$t('股票代码')" align="center" prop="stockCode" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ scope.row.company.stockCode }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('预计上市时间')" align="center" prop="expectedTimeToMarket" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.company.expectedTimeToMarket) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('更新时间')" align="center" prop="updateTime" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="this.$route.query.source === 'BF_PORTFOLIO'" fixed="right" :label="$t('操作')" align="center" class-name="small-padding fixed-width" min-width="220">
          <template slot-scope="scope">
            <el-button
              size="small"
              type="text"
              icon="el-icon-link"
              @click="relationHandle(scope.row)"
            >{{ $t('合作关系') }}</el-button>
            <el-button
              v-hasPermi="['bf:investGroup:edit']"
              size="small"
              type="text"
              icon="el-icon-edit"
              @click="updateHandle(scope.row)"
            >{{ $t('修改') }}</el-button>
            <el-button
              v-hasPermi="['bf:investGroup:remove']"
              size="small"
              type="text"
              icon="el-icon-delete"
              @click="deleteHandle(scope.row)"
            >{{ $t('删除') }}</el-button>
          </template>
        </el-table-column>
        <el-table-column v-else fixed="right" :label="$t('操作')" align="center" class-name="small-padding fixed-width" min-width="220">
          <template slot-scope="scope">
            <el-button
              v-hasPermi="['bf:investGroup:view']"
              size="small"
              type="text"
              icon="el-icon-view"
              @click="dealProjectPenetrationView(scope.row)"
            >{{ $t('穿透图') }}</el-button>
            <el-button
              v-hasPermi="['bf:investGroup:edit']"
              size="small"
              type="text"
              icon="el-icon-edit"
              @click="updateHandle(scope.row)"
            >{{ $t('修改') }}</el-button>
            <el-button
              v-hasPermi="['bf:investGroup:remove']"
              size="small"
              type="text"
              icon="el-icon-delete"
              @click="deleteHandle(scope.row)"
            >{{ $t('删除') }}</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加或修改参股基金_投资组合对话框 -->
      <el-dialog :title="$t(title)" :visible.sync="formOpen" :close-on-click-modal="false" :lock-scroll="false" :destroy-on-close="true" custom-class="dialogForm" append-to-body>
        <bfInvestGroupForm ref="bfInvestGroupForm" :hide-component="this.$route.query.source === 'BF_PORTFOLIO'" />
      </el-dialog>
      <!-- 关系数据对话框 -->
      <el-dialog :title="$t('合作关系')" :visible.sync="relationFormOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
        <company-relation-tabs ref="companyRelationTabs" />
      </el-dialog>

      <el-dialog v-if="forceComponentOpen" :title="$t('项目穿透图')" :visible.sync="forceComponentOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
        <forceComponent ref="forceComponent" :bus-data="forceData" />
      </el-dialog>

      <!-- 导入窗口 -->
      <el-dialog
        :title="$t('导入')"
        :visible.sync="upload.open"
        width="400px"
        :close-on-click-modal="false"
        :lock-scroll="false"
      >
        <div v-loading="upload.isUploading">
          <el-form ref="uploadForm" :model="uploadForm" :rules="uploadRules" label-width="120px" class="dataForm">
            <el-row>
              <el-col :span="24">
                <el-form-item :label="$t('更新时间')" prop="uploadDate">
                  <DatePicker v-model="uploadForm.uploadDate" :pick-options="{}" :placeholder="$t('更新时间')" style="width: 109.5%;" @change="importHandle()" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-upload
            ref="upload"
            :limit="1"
            accept=".xlsx, .xls"
            :headers="upload.headers"
            :action="upload.url"
            :disabled="upload.isUploading"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :on-exceed="handleFileExceed"
            :on-change="handleFileChange"
            :auto-upload="false"
            drag
          >
            <i class="el-icon-upload" />
            <div class="el-upload__text">
              {{ $t("将文件拖到此处，或") }}
              <em>{{ $t("点击上传") }}</em>
            </div>
            <div slot="tip" class="el-upload__tip" style="color: red; display: flex;">
              <div style="height: 36px; line-height: 3;">{{ $t("提示：仅允许导入“xls”或“xlsx”格式文件！") }}</div>
              <div>
                <el-button type="text" @click="downloadTemplate">{{ $t("下载模板") }}</el-button>
                <el-button type="text" @click="exportUpdateHandle">{{ $t("更新数据") }}</el-button>
              </div>
            </div>
          </el-upload>
          <div slot="footer" class="dialog-footer" style="text-align: right">
            <el-button @click="upload.open = false">{{ $t("取消") }}</el-button>
            <el-button type="primary" @click="submitFileForm">{{ $t("确定") }}</el-button>
          </div>
        </div>
      </el-dialog>
      <el-dialog
        :title="$t('导入结果')"
        :visible.sync="dialogVisible"
        width="70%"
        custom-class="menu-dialog-height"
        :close-on-click-modal="false"
        append-to-body
      >
        <div v-loading="checkUploadLoading" style="min-height: 300px; max-height: 500px; overflow: auto;">
          <div v-for="(msg, i) in tableData" :key="i">
            <p v-html="msg" />
          </div>
          <div slot="footer" class="dialog-footer" style="right: 20px;position: absolute;bottom: 20px;">
            <el-button size="small" @click="dialogVisible = false">{{ $t('关闭') }}</el-button>
            <el-button
              v-clipboard:copy="formatHtml(tableData)"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              size="small"
              type="primary"
              icon="el-icon-document-copy"
            >{{ $t('复制信息') }}</el-button>
            <el-button size="small" type="primary" :disabled="JSON.stringify(tableData).includes('color:red')" @click="submitFormUpload">{{ $t('继续导入') }}</el-button>
          </div>
        </div>
      </el-dialog>

    </div>
  </div>
</template>

<script>
import { listBfInvestGroup, delBfInvestGroup, uploadSubmit } from '@/api/bf/investGroup/bfInvestGroup'
import bfInvestGroupForm from './bfInvestGroupForm.vue'
import CompanyRelationTabs from '@/views/company/base/companyRelationTabs'
import forceComponent from '@/components/Deal/forceComponent.vue'
import { allFirstList } from '@/api/system/industry/sysIndustry'
import { getToken } from '@/utils/auth'
import { downLoadFileOpen } from '@/utils/zipdownload'
import bfInvestGroupList from '@/views/bf/investGroup/bfInvestGroupList'
import bfInvestFundList from '@/views/bf/investGroup/bfInvestFundList'
import { getBfBaseIsReverseInvestment } from '@/api/bf/base/bfBase'
import { ruoyiFloat } from '@/utils/ruoyi'

export default {
    components: {
      CompanyRelationTabs,
      bfInvestGroupForm,
      forceComponent,
      bfInvestGroupList,
      bfInvestFundList
    },
  data() {
      return {
          // 遮罩层
          loading: true,
          activeName: 'first',
          // 总条数
          total: 0,
          // 参股基金_投资组合表格数据
          bfInvestGroupList: [],
          // 企业阶段字典
          enterpriseStageOptions: [],
          // 企业阶段字典
          focusIndustryOptions: [],
          // 一级行业
          industryFirstOptions: [],
          // 弹出层标题
          title: '投资组合',
          // 关系数据弹出窗口
          relationFormOpen: false,
          // 是否显示弹出层
          formOpen: false,
          // 查询参数
          dateRange: [],
          queryParams: {
              dealId: this.$route.query.id,
              tagsContext: undefined,
              dealName: undefined,
              companyName: undefined,
              companyShortName: undefined,
              pageNum: 1,
              pageSize: 10
          },
          InvestSummary: {
            companyTotalMoney: undefined,
            underProjectNum: undefined,
            exitProject: undefined,
            mainIndustryPro: undefined,
            mainIndustryMoney: undefined
          },
          // 表单参数
          form: {
            company: {},
            bfPortfolioVo: {}
          },
          // 表单校验
          rules: {
          },
          industryFirstLabel: '',
          forceComponentOpen: undefined,
          forceData: undefined,
           // 项目导入参数
          upload: {
            // 是否显示弹出层（项目导入）
            open: false,
            // 弹出层标题（项目导入）
            title: '',
            // 是否禁用上传
            isUploading: false,
            // 设置上传的请求头部
            headers: { Authorization: 'Bearer ' + getToken() },
            // 上传的地址
            url: ''
          },
          uploadForm: {
            year: undefined,
            quarter: undefined
          },
          uploadRules: {
            uploadDate: [{ required: true, message: this.$t('必填信息'),	trigger: 'blur' }]
          },
          dialogVisible: false,
          tableData: [],
          // 是否有反投
          isReverseInvestment: 'N',
          uploadCheckResult: [],
          checkUploadLoading: false
      }
  },
  created() {
      // 获取所有的一级行业集合
      allFirstList().then(response => {
        this.industryFirstOptions = response.data
      })
      this.getDicts('enterprise_stage').then(response => {
        this.enterpriseStageOptions = response.data
      })
      this.getDicts('deal_industry_focus').then(response => {
        this.focusIndustryOptions = response.data
      })
      this.getList()
      this.getDicts('bf_group_listed_situation').then(response => {
        this.listedSituationOptions = response.data
      })
      this.getDicts('bf_group_listed_sector').then(response => {
        this.listedSectorOptions = response.data
      })
  },
  methods: {
    handleClick(tab) {
      if (tab.name === 'first') {
        this.openGanttEcharts(this.$route.query.id)
      }
      if (tab.name === 'second') {
        this.$nextTick(() => {
          this.$refs.bfInvestFundList.getList()
        })
      }
    },
    openGanttEcharts() {
      this.$nextTick(() => {
        this.$refs.bfInvestGroupList.getList()
      })
    },
    /** 查询参股基金_投资组合列表 */
    getList() {
        this.loading = true
        if (this.$route.query.source !== 'BF_PORTFOLIO' && this.$parent && this.$parent.$parent !== undefined && this.$parent.$parent.getInvestmentSummary !== undefined) {
          // 刷新投资汇总
          this.$parent.$parent.getInvestmentSummary()
          // 查询基金是否有反投
          getBfBaseIsReverseInvestment(this.$route.query.id).then(res => {
            this.isReverseInvestment = res.msg
          })
        }
        listBfInvestGroup(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.bfInvestGroupList = response.rows
            this.total = response.total
            this.loading = false
        })
    },
    // 企业阶段字典翻译
    enterpriseStageFormat(row) {
      return this.selectDictLabel(this.enterpriseStageOptions, row.enterpriseStage)
    },
    // 聚焦行业字典翻译
    focusIndustryFormat(row) {
      return this.selectDictLabel(this.focusIndustryOptions, row.focusIndustry)
    },
    // 查看当前公司的关系数据
    relationHandle(row) {
      this.relationFormOpen = true
      this.$nextTick(() => {
        this.$refs.companyRelationTabs.view = this.$route.query.source
        this.$refs.companyRelationTabs.initData(row.indirectDealId)
      })
    },
    // 上市情况字典翻译
    listedSituationFormat(row) {
      return this.selectDictLabel(this.listedSituationOptions, row.company.listedSituation)
    },
    // 上市板块字典翻译
    listedSectorFormat(row) {
      return this.selectDictLabel(this.listedSectorOptions, row.company.listedSector)
    },
    formatMoney(num) {
      if (isNaN(num)) {
        return 0
      }
      return ruoyiFloat().formatNum(num)
    },
    // 表单重置
    reset() {
        this.form = {
          bfPortfolioVo: {},
          company: {},
            id: undefined,
            dealId: this.$route.query.id,
            dealName: undefined,
            dealCompanyName: undefined,
            companyId: undefined,
            name: undefined,
            sdr: undefined,
            investTime: undefined,
            investmentTime: undefined,
            enterpriseStage: undefined,
            preInvestmentVal: undefined,
            postInvestmentVal: undefined,
            latestValuationOfTheCompany: undefined,
            agreementAmount: undefined,
            transferAmount: undefined,
            focusIndustry: undefined,
            latestShareholdingRatio: undefined,
            remark: undefined,
            createBy: undefined,
            createTime: undefined,
            updateBy: undefined,
            updateTime: undefined,
            delFlag: undefined
        }
        this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
        this.queryParams.pageNum = 1
        this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
        this.dateRange = []
        this.queryParams.tagsContext = undefined
        this.resetForm('queryForm')
        this.queryHandle()
    },
    /** 新增按钮操作 */
    addHandle() {
        this.formOpen = true
        if (this.$route.query.source === 'BF_PORTFOLIO') {
          this.title = '间接项目'
        }
        this.$nextTick(() => {
            this.$refs.bfInvestGroupForm.init(null, this.isReverseInvestment)
        })
    },
    /** 修改按钮操作 */
    updateHandle(row) {
        this.formOpen = true
        if (this.$route.query.source === 'BF_PORTFOLIO') {
          this.title = '间接项目'
        }
        this.$nextTick(() => {
            // 调用form页面的 init 方法初始化数据
            this.$refs.bfInvestGroupForm.init(row, this.isReverseInvestment)
        })
    },
    /** 删除按钮操作 */
    deleteHandle(row) {
        this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
            confirmButtonText: this.$t('确定'),
            cancelButtonText: this.$t('取消'),
            type: 'warning'
        }).then(function() {
            return delBfInvestGroup(row.id)
        }).then(() => {
            this.getList()
            this.msgSuccess(this.$t('删除成功'))
        }).catch(function() {
        })
    },
    dealProjectPenetrationView(row) {
      this.forceData = { busId: row.indirectDealId, busType: 'company', busName: row.company.companyName }
      this.forceComponentOpen = true
    },
    importHandle() {
      var json = { dealId: this.$route.query.id, uploadDate: this.uploadForm.uploadDate }
       this.upload.url = process.env.VUE_APP_BASE_API + '/investGroup/bfInvestGroup/upload?type=' + encodeURIComponent(JSON.stringify(json))
    },
    // 确定上传
    submitFormUpload() {
      if (!this.isEmpty(this.uploadCheckResult)) {
        this.checkUploadLoading = true
        uploadSubmit(this.uploadCheckResult).then(response => {
          this.msgInfo(this.$t(response.msg))
          this.checkUploadLoading = false
          this.dialogVisible = false
          this.getList()
        }).catch(() => {
          this.checkUploadLoading = false
        })
      }
    },
    // 取出html标签
    formatHtml(val) {
      if (!this.isEmpty(val)) {
        var msg = ''
        val.forEach(item => {
          msg += item.replace(/<[^>]+>/g, '') + '\n'
        })
        return msg
      }
      return ''
    },
    onCopy() {
      this.msgSuccess(this.$t('复制成功!'))
    },
    onError() {
      this.msgError(this.$t('复制失败!'))
    },
    downloadTemplate() {
         downLoadFileOpen('/investGroup/bfInvestGroup/download')
    },
    submitFileForm() {
      this.$refs['uploadForm'].validate(valid => {
        if (valid) {
          this.$refs.upload.submit()
        }
      })
    },
     // 文件上传变更时间
    handleFileChange(file, fileList) {
      if (!(file.name.indexOf('xls') >= 0 && file.name.indexOf('xlsx') >= 0)) {
        this.msgError(this.$t('仅允许导入"xls"或"xlsx"格式文件!'))
        fileList.splice(0, 1)
      }
    },
     // 文件达到上限处理
    handleFileExceed() {
      this.msgError(this.$t('可上传文件数量已达到上限'))
    },
    // 文件上传中处理
    handleFileUploadProgress() {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      if (response.msg === 'success') {
        this.msgSuccess(this.$t('导入成功'))
      } else if (response.code === 500) {
        this.msgError(response.msg)
      } else {
        console.log('校验结果:')
        if (this.isEmpty(response.data.dataList)) {
          this.$t('上传的Excel不能为空')
        } else {
          this.uploadCheckResult = response.data.dataList
        }
        if (!this.isEmpty(response.data.errorMessage)) {
          this.dialogVisible = true
          this.tableData = response.data.errorMessage
        }
      }

      this.getList()
    },
    /** 导出按钮操作 */
    exportHandle() {
      this.$confirm(this.$t('是否确认导出数据项?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(() => {
        this.downLoadExcel('/investGroup/bfInvestGroup/export', this.queryParams)
      }).then(response => {
        this.download(response.msg)
      }).catch(() => {
      })
    },
    /** 导出更新数操作 */
    exportUpdateHandle() {
      // this.$confirm(this.$t('是否确认导出数据项?'), this.$t('警告'), {
      //   confirmButtonText: this.$t('确定'),
      //   cancelButtonText: this.$t('取消'),
      //   type: 'warning'
      // }).then(() => {
      //   this.downLoadExcel('/investGroup/bfInvestGroup/exportUpdate', this.queryParams)
      //   // }).then(response => {
      //   //   this.download(response.msg)
      // }).catch(() => {
      // })
      var query = {
        dealId: this.queryParams.dealId,
        tagsContext: this.queryParams.tagsContext,
        dealName: this.queryParams.dealName,
        companyName: this.queryParams.companyName
      }
      this.downLoadExcel('/investGroup/bfInvestGroup/exportUpdate', query)
    }
  }
}
</script>
<style scoped lang="scss">

::v-deep html.light [class^="el-icon-"], html.light [class*=" el-icon-"] {
  display: none !important;
}

::v-deep .el-icon-close-tip {
  display: none !important;
}

/deep/ .el-upload-list__item.is-success.focusing .el-icon-close-tip {
  display: none !important;
}
</style>
